const chatSessionApi = {
    /**
     * 会话列表
     *
     * @param {string} bot 智能体编号
     * @param {string} [keyword] 搜索关键词
     * @returns {Promise<ChatSessionListResponse[]>}
     * @author zero
     */
    lists(bot: string, keyword?: string): Promise<ChatSessionListResponse[]> {
        return $request.get<ChatSessionListResponse[]>({
            url: '/agent/chat/session/lists',
            params: {
                bot,
                keyword
            }
        })
    },

    /**
     * 会话创建
     *
     * @param {string} bot 智能体编号
     * @param {string} name 会话名称
     * @returns {Promise<void>}
     * @author zero
     */
    add(bot: string, name: string): Promise<void> {
        name = name.length > 15 ? name.slice(0, 15) : name
        return $request.post({
            url: '/agent/chat/session/add',
            params: {
                bot,
                name
            }
        })
    },

    /**
     * 会话编辑
     *
     * @param {number} id 会话ID
     * @param {string} name 会话名称
     * @returns {Promise<void>}
     * @author zero
     */
    edit(id: number, name: string): Promise<void> {
        return $request.post({
            url: '/agent/chat/session/edit',
            params: {
                id,
                name
            }
        })
    },

    /**
     * 会话删除
     *
     * @param {number} id 会话ID
     * @returns {Promise<void>}
     * @author zero
     */
    delete(id: number): Promise<void> {
        return $request.post({
            url: '/agent/chat/session/delete',
            params: {
                id
            }
        })
    },

    /**
     * 会话清空
     *
     * @param {string} bot 智能体编号
     * @returns {Promise<void>}
     * @author zero
     */
    clear(bot: string): Promise<void> {
        return $request.post({
            url: '/agent/chat/session/clear',
            params: {
                bot: bot
            }
        })
    }
}

export default chatSessionApi
